package com.xsqf.jt808.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xsqf.jt808.entity.VehicleAuthInfo;
import com.xsqf.jt808.mapper.VehicleAuthInfoMapper;
import com.xsqf.jt808.service.IVehicleAuthInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 鉴权信息
 *
 * @author
 * @since 2020-07-27
 */
@Service
public class VehicleAuthInfoServiceImpl extends ServiceImpl<VehicleAuthInfoMapper, VehicleAuthInfo> implements IVehicleAuthInfoService {

    @Autowired
    private VehicleAuthInfoMapper authInfoMapper;

    @Override
    public VehicleAuthInfo findAllByParameter(String license, String terminalId) {
        QueryWrapper<VehicleAuthInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("deleted", "0");
        if (StringUtils.isNotBlank(license) && "".equals(license)) {
            queryWrapper.eq("license_plate", license);
        }
        if (StringUtils.isNotBlank(terminalId) && "".equals(terminalId)) {
            queryWrapper.eq("terminal_id", terminalId);
        }
        return authInfoMapper.selectOne(queryWrapper);
    }
}
